import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [{
        path: '/',
        name: 'index',
        component: () =>
            import ( /* webpackChunkName: "about" */ '../views/index.vue')
    }, {
        path: '/login',
        component: () =>
            import ('@/views/login/login'),
        hidden: true
    }, {
        path: '/register',
        component: () =>
            import ('@/views/register/register'),
        hidden: true
    }]
    // 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(err => err)
}

export default new VueRouter({
    mode: 'history', // 去掉url中的#
    scrollBehavior: () => ({ y: 0 }),
    routes: routes
})